package cts;

import java.util.Vector;

import javax.swing.JPanel;

import sensor.Sensor;
import houseHold.House;
import houseHold.Room;

public class GUIBuilder {
	
	public static void execute()
	{
		for(int i=0;i<House.getInstance().getRoomCount();i++)
		{
			Room r=House.getInstance().getRoom(i);
			r.builSensorLists();
			if(r.hasGeneral())
			{
				buildGeneralTab(r);
			}
			if(r.getElectricSensors()!=null)
			{
				buildElectricTab(r.getElectricSensors());
			}
			if(r.getGasSensors()!=null)
			{
				buildGasTab(r.getGasSensors());
			}
			if(r.getWaterSensors()!=null)
			{
				buildWaterTab(r.getWaterSensors());
			}
		}
	}

	private static void buildGeneralTab(Room r) {
		Tab general=new Tab();
		general.setName("General");
		SensorPanel panel=new SensorPanel();
		if(r.getTempSensors()!=null)
			panel.addSensors(r.getTempSensors());
		if(r.getLightSensors()!=null)
			panel.addSensors(r.getLightSensors());
		if(r.getPresenceSensors()!=null)
			panel.addSensors(r.getPresenceSensors());
		if(r.getWindowSensors()!=null)
			panel.addSensors(r.getWindowSensors());
		general.setTab(panel);
		
	}

	private static void buildGasTab(Vector<Sensor> gasSensors) {
		Tab gas=new Tab();
		gas.setName("Gas");
		SensorPanel panel=new SensorPanel();
		panel.addSensors(gasSensors);
		gas.setTab(panel);
		
	}


	private static void buildWaterTab(Vector<Sensor> waterSensors) {
		Tab water=new Tab();
		water.setName("Water");
		SensorPanel panel=new SensorPanel();
		panel.addSensors(waterSensors);
		water.setTab(panel);
		
	}

	private static void buildElectricTab(Vector<Sensor> electricSensors) {
		Tab electric=new Tab();
		electric.setName("Electric");
		SensorPanel panel=new SensorPanel();
		panel.addSensors(electricSensors);
		electric.setTab(panel);
		
	}

}
